#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"
#include <math.h>
#include <stdlib.h>
#include <stdio.h>

#define DEBUG 0
#define NOISY_TEST 1

int check_embargo(int card, int choice1, int choice2, int choice3, struct gameState *post, int handPos, int bonus) {
  int i;
  struct gameState pre;
  memcpy (&pre, post, sizeof(struct gameState));

  int r;
  
  r = cardEffect(card, choice1, choice2, choice3, post, handPos, &bonus);
  pre.coins = pre.coins + 2;
  if (pre.supplyCount[choice1] == -1)
     i = -1;
  else{
     pre.embargoTokens[choice1]++;
     discardCard(handPos, pre.whoseTurn, &pre, 1);
     i = 0;
  }
  assert (r == i);

  assert(memcmp(&pre, post, sizeof(struct gameState)) == 0);
  return 0;
}

int main () {

  int i, n, p, r, bonus, handPos;
  
  int k[10] = {adventurer, council_room, feast, gardens, mine,
	       remodel, smithy, village, baron, great_hall};
  int card = embargo;
  struct gameState G;
  printf ("Testing embargo.\n");

  printf ("RANDOM TESTS.\n");

  SelectStream(2);
  PutSeed(3);
  handPos = 2;
  for (n = 0; n < 2000; n++) {
  initializeGame(2, k, 2, &G);
    p = floor(Random() * 2);
    bonus = floor(Random() * 10);
    G.coins = floor(Random() * 20);
    check_embargo(card, 1, -1, -1, &G, handPos, bonus); 
  }


  printf ("ALL TESTS OK\n");

  return 0;
}
